Skip to content

feat!: Upgrade LLVM code in tket-qsystem and qis-compiler#1422

Open
cgh-qtnm wants to merge 24 commits intomainfrom
george/llvmup
Open

feat!: Upgrade LLVM code in tket-qsystem and qis-compiler#1422
cgh-qtnm wants to merge 24 commits intomainfrom
george/llvmup

Conversation

@cgh-qtnm
Copy link

@cgh-qtnm cgh-qtnm commented Feb 26, 2026

BREAKING CHANGE: The hugr-llvm LLVM version is being upgraded to 21.1, and code that depends on it here needs to be updated as well. This also includes an MSRV change to 1.91 to match hugr. See the hugr PR for details.

Closes #1421

@hugrbot
Copy link
Collaborator

hugrbot commented Feb 26, 2026

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building tket v0.17.0 (current)
error: running cargo-doc on crate 'tket' failed with output:
-----
 Compiling proc-macro2 v1.0.106
 Compiling unicode-ident v1.0.24
 Compiling quote v1.0.45
 Compiling libc v0.2.183
 Compiling serde_core v1.0.228
 Compiling serde v1.0.228
 Compiling shlex v1.3.0
 Compiling find-msvc-tools v0.1.9
 Compiling syn v2.0.117
 Compiling autocfg v1.5.0
 Compiling jobserver v0.1.34
 Compiling num-traits v0.2.19
 Compiling cc v1.2.57
  Checking once_cell v1.21.4
  Checking either v1.15.0
  Checking memchr v2.8.0
  Checking cfg-if v1.0.4
 Compiling version_check v0.9.5
  Checking hashbrown v0.16.1
  Checking equivalent v1.0.2
 Compiling semver v1.0.27
 Compiling crossbeam-utils v0.8.21
  Checking indexmap v2.13.0
 Compiling lazy_static v1.5.0
 Compiling pkg-config v0.3.32
 Compiling radium v0.7.0
 Compiling anyhow v1.0.102
 Compiling zstd-sys v2.0.16+zstd.1.5.7
 Compiling unicode-segmentation v1.12.0
 Compiling ucd-trie v0.1.7
 Compiling zmij v1.0.21
 Compiling strsim v0.11.1
  Checking tap v1.0.1
 Compiling thiserror v2.0.18
 Compiling thiserror v1.0.69
 Compiling ident_case v1.0.1
 Compiling darling_core v0.23.0
  Checking wyz v0.5.1
 Compiling pest v2.8.6
 Compiling convert_case v0.10.0
 Compiling serde_derive v1.0.228
 Compiling thiserror-impl v1.0.69
 Compiling thiserror-impl v2.0.18
 Compiling typeid v1.0.3
  Checking foldhash v0.1.5
  Checking itoa v1.0.17
 Compiling serde_json v1.0.149
 Compiling getrandom v0.4.2
  Checking funty v2.0.0
 Compiling unicode-xid v0.2.6
 Compiling derive_more-impl v2.1.1
  Checking hashbrown v0.15.5
 Compiling darling_macro v0.23.0
 Compiling pest_meta v2.8.6
  Checking smallvec v1.15.1
  Checking bitvec v1.0.1
  Checking crossbeam-epoch v0.9.18
 Compiling slotmap_fork_lmondada v1.0.8
 Compiling convert_case v0.4.0
 Compiling winnow v0.7.15
  Checking pin-project-lite v0.2.17
 Compiling ref-cast v1.0.25
  Checking fixedbitset v0.5.7
 Compiling erased-serde v0.4.10
 Compiling zerocopy v0.8.42
 Compiling zstd-safe v7.2.4
 Compiling heck v0.5.0
 Compiling rayon-core v1.13.0
 Compiling paste v1.0.15
 Compiling regex-lite v0.1.9
 Compiling strum_macros v0.28.0
 Compiling llvm-sys v211.0.0
 Compiling toml_parser v1.0.9+spec-1.1.0
  Checking petgraph v0.8.3
 Compiling derive_more v0.99.20
  Checking derive_more v2.1.1
  Checking crossbeam-deque v0.8.6
 Compiling pest_generator v2.8.6
 Compiling darling v0.23.0
 Compiling ref-cast-impl v1.0.25
 Compiling serde_derive_internals v0.29.1
 Compiling aho-corasick v1.1.4
 Compiling rustc_version v0.4.1
 Compiling ahash v0.8.12
  Checking itertools v0.14.0
 Compiling regex-syntax v0.8.10
  Checking typed-arena v2.0.2
  Checking rustc-hash v2.1.1
 Compiling rustix v1.1.4
  Checking arrayvec v0.5.2
 Compiling typetag v0.2.21
 Compiling toml_datetime v1.0.0+spec-1.1.0
  Checking byteorder v1.5.0
  Checking unicode-width v0.2.2
 Compiling cgmath v0.18.0
 Compiling regex-automata v0.4.14
  Checking pretty v0.12.5
  Checking fxhash v0.2.1
 Compiling toml_edit v0.25.4+spec-1.1.0
 Compiling schemars_derive v1.2.1
 Compiling rstest_macros v0.26.1
 Compiling pest_derive v2.8.6
 Compiling serde_with_macros v3.18.0
  Checking strum v0.28.0
  Checking ordered-float v5.1.0
 Compiling tracing-attributes v0.1.31
 Compiling typetag-impl v0.2.21
 Compiling derive-where v1.6.1
 Compiling delegate v0.13.5
  Checking itertools v0.13.0
  Checking smol_str v0.3.6
  Checking tracing-core v0.1.36
  Checking approx v0.4.0
  Checking capnp v0.25.2
 Compiling syn v1.0.109
 Compiling parking_lot_core v0.9.12
  Checking dyn-clone v1.0.20
  Checking inventory v0.3.22
  Checking base64 v0.22.1
  Checking bumpalo v3.20.2
  Checking bitflags v2.11.0
  Checking utf8-width v0.1.8
  Checking linux-raw-sys v0.12.1
  Checking html-escape v0.2.13
  Checking hugr-model v0.26.0
 Compiling enum_dispatch v0.3.13
  Checking relrc v0.5.0
  Checking schemars v1.2.1
  Checking tracing v0.1.44
  Checking portgraph v0.15.3
  Checking serde_with v3.18.0
  Checking rayon v1.11.0
  Checking zstd v0.13.3
  Checking regex v1.12.3
 Compiling proc-macro-crate v3.5.0
 Compiling futures-macro v0.3.32
 Compiling fixedbitset v0.4.2
 Compiling glob v0.3.3
 Compiling relative-path v1.9.3
  Checking fastrand v2.3.0
  Checking slab v0.4.12
  Checking static_assertions v1.1.0
  Checking downcast-rs v2.0.2
  Checking allocator-api2 v0.2.21
  Checking futures-core v0.3.32
 Compiling pastey v0.2.1
  Checking scopeguard v1.2.0
 Compiling inkwell v0.8.0
  Checking futures-task v0.3.32
  Checking futures-util v0.3.32
  Checking hugr-core v0.26.0
  Checking hashbrown v0.14.5
  Checking lock_api v0.4.14
  Checking tempfile v3.27.0
 Compiling petgraph v0.6.5
 Compiling ascent_base v0.8.0
error: No suitable version of LLVM was found system-wide or pointed
            to by LLVM_SYS_211_PREFIX.
     
            Consider using `llvmenv` to compile an appropriate copy of LLVM, and
            refer to the llvm-sys documentation for more information.
     
            llvm-sys: https://crates.io/crates/llvm-sys
            llvmenv: https://crates.io/crates/llvmenv
 --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/llvm-sys-211.0.0/src/lib.rs:532:1
  |
532 | / std::compile_error!(concat!(
533 | |     "No suitable version of LLVM was found system-wide or pointed
534 | |        to by LLVM_SYS_",
535 | |     env!("CARGO_PKG_VERSION_MAJOR"),
...   |
542 | |        llvmenv: https://crates.io/crates/llvmenv"
543 | | ));
  | |__^

error: could not compile `llvm-sys` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

-----

error: failed to build rustdoc for crate tket v0.17.0
note: this is usually due to a compilation error in the crate,
    and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the error:
    cargo new --lib example &&
        cd example &&
        echo '[workspace]' >> Cargo.toml &&
        cargo add --path /home/runner/work/tket2/tket2/PR_BRANCH/tket --features binary-eccs,default,llvm,portmatching,rewrite-tracing &&
        cargo check &&
        cargo doc

  Building tket-qsystem v0.23.0 (current)
error: running cargo-doc on crate 'tket-qsystem' failed with output:
-----
 Compiling proc-macro2 v1.0.106
 Compiling unicode-ident v1.0.24
 Compiling quote v1.0.45
 Compiling libc v0.2.183
 Compiling serde_core v1.0.228
 Compiling shlex v1.3.0
  Checking once_cell v1.21.4
 Compiling find-msvc-tools v0.1.9
  Checking cfg-if v1.0.4
 Compiling syn v2.0.117
 Compiling jobserver v0.1.34
 Compiling cc v1.2.57
 Compiling autocfg v1.5.0
 Compiling serde v1.0.228
 Compiling num-traits v0.2.19
  Checking memchr v2.8.0
 Compiling version_check v0.9.5
  Checking either v1.15.0
 Compiling heck v0.5.0
 Compiling semver v1.0.27
 Compiling hashbrown v0.16.1
 Compiling equivalent v1.0.2
 Compiling anyhow v1.0.102
 Compiling crossbeam-utils v0.8.21
 Compiling pkg-config v0.3.32
 Compiling indexmap v2.13.0
 Compiling lazy_static v1.5.0
 Compiling zstd-sys v2.0.16+zstd.1.5.7
  Checking smallvec v1.15.1
 Compiling unicode-segmentation v1.12.0
  Checking unicode-width v0.2.2
 Compiling thiserror v2.0.18
 Compiling strsim v0.11.1
 Compiling ident_case v1.0.1
 Compiling ucd-trie v0.1.7
 Compiling zmij v1.0.21
 Compiling getrandom v0.4.2
 Compiling pest v2.8.6
 Compiling darling_core v0.23.0
 Compiling convert_case v0.10.0
 Compiling unicode-xid v0.2.6
 Compiling typeid v1.0.3
 Compiling serde_derive v1.0.228
 Compiling thiserror-impl v2.0.18
  Checking itoa v1.0.17
 Compiling radium v0.7.0
  Checking foldhash v0.1.5
 Compiling serde_json v1.0.149
  Checking hashbrown v0.15.5
 Compiling darling_macro v0.23.0
 Compiling derive_more-impl v2.1.1
 Compiling pest_meta v2.8.6
 Compiling slotmap_fork_lmondada v1.0.8
  Checking tracing-core v0.1.36
  Checking fixedbitset v0.5.7
 Compiling thiserror v1.0.69
 Compiling regex-lite v0.1.9
  Checking tap v1.0.1
 Compiling rustix v1.1.4
 Compiling winnow v0.7.15
  Checking pin-project-lite v0.2.17
 Compiling ref-cast v1.0.25
 Compiling erased-serde v0.4.10
 Compiling zstd-safe v7.2.4
  Checking derive_more v2.1.1
 Compiling llvm-sys v211.0.0
  Checking wyz v0.5.1
  Checking petgraph v0.8.3
 Compiling toml_parser v1.0.9+spec-1.1.0
 Compiling pest_generator v2.8.6
 Compiling darling v0.23.0
 Compiling strum_macros v0.28.0
 Compiling ref-cast-impl v1.0.25
 Compiling thiserror-impl v1.0.69
  Checking crossbeam-epoch v0.9.18
 Compiling serde_derive_internals v0.29.1
 Compiling rustc_version v0.4.1
  Checking itertools v0.14.0
 Compiling aho-corasick v1.1.4
 Compiling zerocopy v0.8.42
  Checking bitflags v2.11.0
  Checking funty v2.0.0
  Checking regex-syntax v0.8.10
  Checking typed-arena v2.0.2
 Compiling rayon-core v1.13.0
  Checking linux-raw-sys v0.12.1
  Checking rustc-hash v2.1.1
 Compiling typetag v0.2.21
 Compiling convert_case v0.4.0
  Checking byteorder v1.5.0
 Compiling paste v1.0.15
 Compiling cgmath v0.18.0
  Checking arrayvec v0.5.2
 Compiling toml_datetime v1.0.0+spec-1.1.0
  Checking regex-automata v0.4.14
 Compiling toml_edit v0.25.4+spec-1.1.0
  Checking pretty v0.12.5
 Compiling derive_more v0.99.20
  Checking fxhash v0.2.1
  Checking bitvec v1.0.1
  Checking strum v0.28.0
 Compiling schemars_derive v1.2.1
 Compiling rstest_macros v0.26.1
  Checking crossbeam-deque v0.8.6
 Compiling pest_derive v2.8.6
 Compiling serde_with_macros v3.18.0
  Checking ordered-float v5.1.0
 Compiling derive-where v1.6.1
 Compiling tracing-attributes v0.1.31
 Compiling typetag-impl v0.2.21
 Compiling delegate v0.13.5
  Checking approx v0.4.0
  Checking itertools v0.13.0
 Compiling ahash v0.8.12
  Checking smol_str v0.3.6
  Checking utf8parse v0.2.2
  Checking dyn-clone v1.0.20
  Checking fastrand v2.3.0
  Checking utf8-width v0.1.8
  Checking bumpalo v3.20.2
  Checking inventory v0.3.22
  Checking capnp v0.25.2
  Checking base64 v0.22.1
 Compiling enum_dispatch v0.3.13
  Checking tempfile v3.27.0
  Checking relrc v0.5.0
  Checking html-escape v0.2.13
  Checking tracing v0.1.44
  Checking schemars v1.2.1
  Checking anstyle-parse v1.0.0
  Checking portgraph v0.15.3
  Checking hugr-model v0.26.0
  Checking serde_with v3.18.0
  Checking zstd v0.13.3
 Compiling regex v1.12.3
 Compiling proc-macro-crate v3.5.0
 Compiling futures-macro v0.3.32
  Checking downcast-rs v2.0.2
  Checking is_terminal_polyfill v1.70.2
  Checking slab v0.4.12
  Checking anstyle-query v1.1.5
 Compiling pastey v0.2.1
  Checking static_assertions v1.1.0
 Compiling glob v0.3.3
  Checking futures-core v0.3.32
  Checking anstyle v1.0.14
 Compiling parking_lot_core v0.9.12
 Compiling relative-path v1.9.3
  Checking futures-task v0.3.32
  Checking colorchoice v1.0.5
 Compiling inkwell v0.8.0
  Checking futures-util v0.3.32
  Checking anstream v1.0.0
  Checking hugr-core v0.26.0
  Checking rayon v1.11.0
error: No suitable version of LLVM was found system-wide or pointed
            to by LLVM_SYS_211_PREFIX.
     
            Consider using `llvmenv` to compile an appropriate copy of LLVM, and
            refer to the llvm-sys documentation for more information.
     
            llvm-sys: https://crates.io/crates/llvm-sys
            llvmenv: https://crates.io/crates/llvmenv
 --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/llvm-sys-211.0.0/src/lib.rs:532:1
  |
532 | / std::compile_error!(concat!(
533 | |     "No suitable version of LLVM was found system-wide or pointed
534 | |        to by LLVM_SYS_",
535 | |     env!("CARGO_PKG_VERSION_MAJOR"),
...   |
542 | |        llvmenv: https://crates.io/crates/llvmenv"
543 | | ));
  | |__^

error: could not compile `llvm-sys` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

-----

error: failed to build rustdoc for crate tket-qsystem v0.23.0
note: this is usually due to a compilation error in the crate,
    and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the error:
    cargo new --lib example &&
        cd example &&
        echo '[workspace]' >> Cargo.toml &&
        cargo add --path /home/runner/work/tket2/tket2/PR_BRANCH/tket-qsystem --features cli,default,llvm &&
        cargo check &&
        cargo doc

error: aborting due to failure to build rustdoc for crate tket v0.17.0

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.54%. Comparing base (b82a771) to head (4667e80).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1422      +/-   ##
==========================================
- Coverage   79.65%   79.54%   -0.11%     
==========================================
  Files         155      155              
  Lines       20335    19943     -392     
  Branches    19345    18953     -392     
==========================================
- Hits        16197    15864     -333     
+ Misses       3180     3159      -21     
+ Partials      958      920      -38     
Flag Coverage Δ
python 93.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jake-arkinstall
Copy link
Contributor

jake-arkinstall commented Feb 26, 2026

Note that devenv.nix in this repo and the hugr repo will need to be updated to provide the newer LLVM and its path in env vars for local development.

If that's already been done, ignore this - the file list is pretty huge. I'm happy to do that change otherwise.

@cgh-qtnm
Copy link
Author

Note that devenv.nix in this repo and the hugr repo will need to be updated to provide the newer LLVM and its path in env vars for local development.

If that's already been done, ignore this - the file list is pretty huge. I'm happy to do that change otherwise.

I haven't done this, good catch. I'd appreciate if you make the change - better if it's tested by a devenv user anyway.

@cgh-qtnm cgh-qtnm marked this pull request as ready for review March 2, 2026 15:40
@cgh-qtnm cgh-qtnm requested a review from a team as a code owner March 2, 2026 15:40
Cargo.lock Outdated
version = "0.25.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6baee3cc2fe4d7c5635a630341e28237f12a8e5beef31b5aaaebe93bc9ba90a"
source = "git+https://github.com/quantinuum/hugr?branch=george%2Fllvmup#7d8587c64086ea5a2a4486b23ef7b73ab2c44040"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we want to be depending on these branches from main here. Should we wait for an updated release of hugr?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my plan is to release hugr first and change these to point to the release before merging.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I hope to merge the HUGR PR + this PR + the internal PR in quick succession, hence putting them up for review together.

@cqc-alec
Copy link
Collaborator

cqc-alec commented Mar 2, 2026

Have given it a superficial review (and ignored all the snaps assuming those changes make sense). LGTM!

@cgh-qtnm
Copy link
Author

cgh-qtnm commented Mar 16, 2026

@aborgna-q This should be ready for you to merge into the release branch. Notes:

  1. Fixed what Iooks like a bug where BoolOp::not had a signature with two inputs.
  2. Wrap a bunch of TypeBase<NoRV> in vec! so that they will cast to a single-element TypeRowBase<NoRV>. Unless I'm missing something this is just due to an oversight in the type row code, we should fix it in the next HUGR release. If there's a cleaner way to fix this feel free to revert and replace.
  3. Removed remnants of stack array support.

Still a few bugs. In particular, the one about failure to monomorphize _range_comptime in the qis-compiler tests might be a hugr-llvm problem, but I'm not sure exactly what's going wrong. Let me know if further attention is needed there from me.

@aborgna-q aborgna-q self-assigned this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to LLVM 21

5 participants